package com.wontube.smr.remote.admin;

import java.util.List;

import com.wontube.client.modle.vo.PagenateInfo;
import com.wontube.core.annotation.NoLoginSupport;
import com.wontube.core.cache.Cacher;
import com.wontube.core.cache.EHCacheKey;
import com.wontube.core.pub.servlet.handlers.BasicHandler;
import com.wontube.smr.bo.sites.hulu.HuluObtainBO;
import com.wontube.smr.client.IMovieHandler;
import com.wontube.smr.client.model.po.Movie;
import com.wontube.smr.client.model.po.Tool;
import com.wontube.smr.client.model.po.ToolDetail;
import com.wontube.smr.client.model.vo.ToolItems;
import com.wontube.smr.dao.bo.ToolDao;
import com.wontube.smr.web.client.admin.IAdminHandler;

@NoLoginSupport
public class AdminHandler extends BasicHandler implements IAdminHandler {
	@Override
	public Boolean updateVideoBanner(Movie movie) {
		HuluObtainBO.updateVideoBanner(movie);
		
		// 删除管理界面缓存
		String clazzName = IMovieHandler.class.getName();
		String methodName = "selectHuluWeekPopular";

		PagenateInfo pageInfo = new PagenateInfo(1, 10);
		Object[] args = new Object[] { pageInfo };
		Cacher.defaultCacher.deleteCache(clazzName, methodName, new EHCacheKey(args));
		
		return Boolean.TRUE;
	}
	
	@Override
	public int saveOrUpdateToolDetail(ToolDetail tool) {
		ToolDao.saveOrUpdateToolDetail(tool);
		return 0;
	}

	@Override
	public List<ToolDetail> selectToolDetailById(String toolId) {
		return ToolDao.selectToolDetailById(toolId);
	}

	@Override
	public ToolItems selectTool(String type, PagenateInfo pageInfo) {
		return ToolDao.selectTool(type, pageInfo);
	}

	@Override
	public int insertTool(Tool tool) {
		return ToolDao.insertTool(tool);
	}

	@Override
	public int updateTool(Tool tool) {
		return 0;
	}

	public int deleteTool(String id) {
		return ToolDao.deleteTool(id);
	}

	@Override
	public ToolItems selectTool(String type) {
		return ToolDao.selectTool(type);
	}

	@Override
	public Tool selectToolById(String id) {
		return ToolDao.selectToolById(id);
	}

}
